package com.poc.service.impl;

import com.poc.domain.Task;
import com.poc.domain.TaskStatus;
import com.poc.repository.TaskProcessorRepository;
import com.poc.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class TaskServiceImpl implements TaskService {
    @Autowired
    private TaskProcessorRepository taskRepository;


    @Override
    public Task updateTask(Integer taskId) {
        Optional<Task> updateTask = taskRepository.findById(taskId);
        if (updateTask.isPresent()) {
            updateTask.get().setTask_status(TaskStatus.completed.getStatus());
            return taskRepository.save(updateTask.get());
        }
        return null;
    }
}
